<?php 
/**
 * eBay Label Printing Program Backoffice CMS Sub Controller 
 * This is the sub controller for Administrator manage website Documents
 * @package  eBayLabelPrinter
 * @category Controller
 * @author   Norman Dong <norman.dong@hotmail.com>
 * @version  Initial
 * @copyright LeadCasket.com
 * @link     www.leadcasket.com
 * @license  Commercial
 */
class Backoffice_CmsController extends Zend_Controller_Action
{


    public function indexAction(){
	
		echo "Back Office CMS Sub Controller";	
    
	}
	
	public function addArticleAction(){
	//init article form 
	$formArticle = new Form_Article();
	$this->view->formarticle = $formArticle;
	//
	if($this->getRequest()->isPost()){
		$formData = $this->getRequest()->getPost();
		if($formArticle->isValid($formData)){	
			$newArticle = new Model_DbTable_Article();
			
			$articleTitle = $formArticle->getValue('title_article');
			$articleDate = $formArticle->getValue('title_date');
			$articlePositon = $formArticle->getValue('title_position');
			$articleFrontpage = $formArticle->getValue('title_frontpage');
			$articleSection = $formArticle->getValue('title_secion');
			$articleCategory = $formArticle->getValue('title_category');															
			$articleContent = $formArticle->getValue('title_content');
						
			$newArticle->addArticle($articleTitle, $articleDate, $articlePosition, $articleFrontpage, $articleSection, $articleCategory, $articleContent);
			}
		else{
			$formArticle->populate($formData);
			}	
		}	
		
	}
	
	public function deleteArticleAction(){
		
	}
	
	public function editArticleAction(){
		//init article form
		$formArticle = new Form_Article();
		$this->view->formarticle = $formArticle;
		//
		if($this->getRequest()->isPost()){
			$formData = $this->getRequest()->getPost();
			if($formArticle->isValid($formData)){
				
				$updateArticle = new Model_DbTable_Article();
				$articleID = $formArticle->getValue('id_article');	
				$articleTitle = $formArticle->getValue('title_article');
				$articleDate = $formArticle->getValue('title_date');
				$articlePositon = $formArticle->getValue('title_position');
				$articleFrontpage = $formArticle->getValue('title_frontpage');
				$articleSection = $formArticle->getValue('title_secion');
				$articleCategory = $formArticle->getValue('title_category');
				$articleContent = $formArticle->getValue('title_content');
		
				$updateArticle->updateArticle($articleID, $articleTitle, $articleDate, $articlePosition, $articleFrontpage, $articleSection, $articleCategory, $articleContent);
			}
			else{
				$formArticle->populate($formData);
			}
		}
		
		
	}			
	//	
	public function listArticleAction(){
		
	}

	public function addSectionAction(){
		
	}
		
	public function deleteSectionAction(){
		
	}
	public function editSectionAction(){
		
	}
	public function listSectionAction(){
		
	}		
	public function addCategoryAction(){
	
	}
	
	public function deleteCategoryAction(){
	
	}
	public function editCategoryAction(){
	
	}
	public function listCategoryAction(){
	
	}			

}
?>